﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine.EventSystems;
using UnityEngine;
using System;

public class UIDragListener : MonoBehaviour, IEndDragHandler
{
    Action<PointerEventData> onEndDrag;
    public static void RectEndHanler(GameObject obj, Action<PointerEventData> cb) {

        UIDragListener target = obj.GetComponent<UIDragListener>();
        if (target == null)
        {
            target = obj.AddComponent<UIDragListener>();
        }
        target.onEndDrag = cb;
    }
    public void OnEndDrag(PointerEventData eventData)
    {
        if (onEndDrag != null)
        {
            onEndDrag(eventData);
        }
    }
}
